package com.hhc.controller.scene_master;

import com.alibaba.fastjson.JSONObject;
import com.hhc.model.SceneMaster;
import com.hhc.service.SceneMasterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/sceneMaster")
public class SceneMasterController {
    @Autowired
    private SceneMasterService sceneMasterService;

    @RequestMapping(value = "/addScene", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject addScene(@RequestBody String data) {
        JSONObject jsonObject;
        SceneMaster sceneMaster = JSONObject.parseObject(data, SceneMaster.class);
        jsonObject = sceneMasterService.addScene(sceneMaster);
        return jsonObject;
    }

    @RequestMapping(value = "/querySceneList", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject querySceneList(@RequestBody String data) {
        JSONObject jsonObject;
        SceneMaster sceneMaster = JSONObject.parseObject(data, SceneMaster.class);
        jsonObject = sceneMasterService.querySceneList(sceneMaster);
        return jsonObject;
    }

    @RequestMapping(value = "/deleteScene", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteScene(@RequestBody String data) {
        JSONObject jsonObject;
        SceneMaster sceneMaster = JSONObject.parseObject(data, SceneMaster.class);
        jsonObject = sceneMasterService.deleteScene(sceneMaster);
        return jsonObject;
    }

    @RequestMapping(value = "/updateSceneName", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateSceneName(@RequestBody String data) {
        JSONObject jsonObject;
        SceneMaster sceneMaster = JSONObject.parseObject(data, SceneMaster.class);
        jsonObject = sceneMasterService.updateSceneName(sceneMaster);
        return jsonObject;
    }
}
